﻿#include <iostream>
#include <cstdlib>   // 包含rand()和srand()
#include <ctime>     // 包含time()

using namespace std;

int rollDice() {
    return rand() % 6 + 1;  // 生成1-6的随机数
}

int main() {
    // 初始化随机数种子
    srand(time(0));

    char choice;

    cout << "🎲 欢迎使用虚拟骰子模拟器 🎲" << endl;

    do {
        cout << "\n按回车键掷骰子...";
        cin.ignore();  // 等待用户按下回车

        int result = rollDice();

        // 显示骰子点数ASCII艺术
        cout << "\n╭───────╮\n";
        cout << "│  ●    │\n";
        cout << "│ ";
        switch (result) {
        case 1: cout << "   "; break;
        case 2: cout << "●  "; break;
        case 3: cout << "●  "; break;
        case 4: cout << "● ●"; break;
        case 5: cout << "● ●"; break;
        case 6: cout << "● ●"; break;
        }
        cout << " │\n";
        cout << "│    ●  │\n";
        cout << "╰───────╯\n";
        cout << "结果是: " << result << endl;

        cout << "\n再掷一次？(y/n): ";
        cin >> choice;
    } while (choice == 'y' || choice == 'Y');

    cout << "\n游戏结束，欢迎下次使用！" << endl;
    return 0;
}